package com.tuo51.core.repositories;

import com.tuo51.core.domain.staffs.Staff;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;

import java.util.List;

public interface StaffRepository extends JpaRepository<Staff, String>, JpaSpecificationExecutor<Staff> {

    List<Staff> findAllByMobileAndSourceAppIdAndPlatformAndDeletedIsFalse(String mobile, String sourceAppId, int platform);
    List<Staff> findAllByMobileAndPlatformAndDeletedIsFalse(String mobile, int platform);

    List<Staff> findAllByMobileAndPlatformAndDeletedIsFalseAndOpenidMPIsNotNull(String mobile, int platform);
    List<Staff> findAllByMobileAndSourceAppIdAndPlatformAndDeletedIsFalseAndOpenidMPIsNotNull(String mobile, String sourceAppId, int platform);

    List<Staff> findAllByOrgIdAndPlatform(String orgId, int platform);

    Staff getByOpenidMAAndSourceAppId(String openid_ma, String sourceAppId);
    Staff getByOpenidMPAndSourceAppId(String openid_mp, String sourceAppId);
    Staff getByUnionidAndSourceAppId(String unionId, String sourceAppId);
    Staff getByUnionidAndIdNotAndSourceAppId(String unionId, String notId, String sourceAppId);

    Staff getByUnionidAndSourceAppIdAndTemporallyIsFalse(String unionId, String sourceAppId);
    Staff getByOpenidMAAndSourceAppIdAndTemporallyIsFalse(String openid_ma, String sourceAppId);
    Staff getByUnionidAndSourceAppIdAndTemporallyIsTrue(String unionId, String sourceAppId);
    Staff getByOpenidMAAndSourceAppIdAndTemporallyIsTrue(String openid_ma, String sourceAppId);

    Staff getBySessionKeyAndSourceAppId(String sessionKey, String sourceAppId);

    List<Staff> findByIdIn(String[] id);

    Staff findStaffById(String id);

}
